'''
Author: thinktanker thinktanker@163.com
Date: 2024-08-22 16:02:44
LastEditors: thinktanker thinktanker@163.com
LastEditTime: 2024-08-26 15:52:29
FilePath: 
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
import requests
import time

BASEURL = "http://10.32.227.209:8821"
LOGIN = "/permissions/auth/api/login"
HEADERS = {
    "User-Agent":
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"
}
login_json = {
    "username": "lljtp",
    "password": "22fb7fb294f45089c045cb5c325c6fc9"
}
session = requests.Session()
resp = session.post(url=f"{BASEURL}{LOGIN}", headers=HEADERS, json=login_json)
resp_json = resp.json()
print(resp_json)
userId = resp_json["data"]["userId"]
userCipher = resp_json["data"]["userCipher"]
token = resp_json["token"]
print(userId, token)
SAVE = "/studio-server/api/save"
'''
id 从这里返回
'''
save_json = {
    "modelKey": "SHUI_BENG_PIN_JI",
    "dataSourceKey": "babao",
    "childModels": [],
    "siblingModels": [],
    "data": {
        "LI_N_ZH_U3_ID": "1",
        "LI_N_ZH_U2": "合格",
        "D_NG_J1": "一",
        "LI_N_ZH_U1": "合格",
        "D_NG_J2": "一",
        "D_NG_J3": "一",
        "LI_N_ZH_U3": "合格",
        "D_NG_J4": "一",
        "D_NG_J6_ID": "1",
        "D_NG_J5": "一",
        "D_NG_J6": "一",
        "D_NG_J7": "一",
        "D_NG_J8": "一",
        "ZH_SH_X_N_H_O1": "合格",
        "D_NG_J9": "一",
        "ZH_SH_X_N_H_O2": "合格",
        "PROCESS_NODE_KEY": None,
        "PROCESS_STATE": None,
        "J_L_R_N_ID": "d136a5a3f12543d59b5c1e72bd34a1b8",
        "id": "b9b811785a224934b26abbf863f72962",
        "S_N_L_I_SH_LI_NG": None,
        "SHU_B_NG_D_O_ZH_U3": "合格",
        "Y_N_H_NG_X_NG_N_NG3_ID": "1",
        "SHU_B_NG_D_O_ZH_U4": "合格",
        "SHU_B_NG_D_O_ZH_U1": "合格",
        "SHU_B_NG_D_O_ZH_U2": "合格",
        "PROCESS_ID": None,
        "D_NG_J3_ID": "1",
        "TI_N_LI_O_ID": "1",
        "SHU_B_NG_D_O_ZH_U2_ID": "1",
        "Y_PI_N3_ID": "1",
        "J_SH3_ID": "1",
        "deleted_at": None,
        "JI_N_CH_R_N": "徐楠",
        "B_I_ZH9": None,
        "Y_L_N_SH3": "合格",
        "SHU_B_NG1_ID": "1",
        "Y_L_N_SH2": "合格",
        "D_NG_J12_ID": "1",
        "Y_L_N_SH1": "合格",
        "J_SH3": "合格",
        "deletor": None,
        "J_SH2": "合格",
        "creator_id": userId,
        "updater_id": userId,
        "J_SH1": "合格",
        "B_I_ZH1": None,
        "B_I_ZH2": None,
        "B_I_ZH3": None,
        "S_N_L_I_B_I_F_N_B": None,
        "B_I_ZH4": None,
        "B_I_ZH5": None,
        "G_NG_CH_NG_M_NG_CH_NG": None,
        "B_I_ZH6": None,
        "B_I_ZH7": None,
        "B_I_ZH8": None,
        "D_NG_J4_ID": "1",
        "SHU_B_NG_D_O_ZH_U3_ID": "1",
        "PROCESS_HANDLER_NAMES_ID": None,
        "N_ZHU_NG_Y_O_QI_ID": "1",
        "created_at": "2024-08-26 10:07:47",
        "Z_R_N_R_N_ID": "d136a5a3f12543d59b5c1e72bd34a1b8",
        "P_NG_D_NG_D_NG_J": "一级",
        "R_L_I_B_I_F_N_B": None,
        "J_N_R_N_K_NG_ID": "1",
        "updated_at": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
        "D_NG_J11_ID": "1",
        "Y_L_N_SH3_ID": "1",
        "Y_N_H_NG_X_NG_N_NG1_ID": "1",
        "SHU_B_NG2": "合格",
        "SHU_B_NG_W_I_K2_ID": "1",
        "Y_L_I_SH_LI_NG": None,
        "SHU_B_NG1": "合格",
        "PROCESS_NODE": None,
        "SHU_B_NG3": "合格",
        "ZH_SH_X_N_H_O1_ID": "1",
        "Y_N_H_NG_X_NG_N_NG3": "合格",
        "LI_N_ZH_U2_ID": "1",
        "creator": "唐鹏",
        "Y_N_H_NG_X_NG_N_NG1": "合格",
        "Y_N_H_NG_X_NG_N_NG2": "合格",
        "J_SH1_ID": "1",
        "D_NG_J9_ID": "1",
        "D_NG_J1_ID": "1",
        "P_NG_D_NG_R_Q": "2024-03-14 00:00:00",
        "SHU_B_NG3_ID": "1",
        "D_NG_J2_ID": "1",
        "Y_PI_N2_ID": "1",
        "PAGEHELPER_ROW_ID": 1,
        "J_SH2_ID": "1",
        "SHU_B_NG_D_O_ZH_U1_ID": "1",
        "Y_L_N_SH1_ID": "1",
        "Y_L_I_B_I_F_N_B": None,
        "SHU_B_NG2_ID": "1",
        "PROCESS_STATE_ID": None,
        "SHU_B_NG_D_O_ZH_U4_ID": "1",
        "D_NG_J7_ID": "1",
        "JI_N_CH_R_N_ID": "d136a5a3f12543d59b5c1e72bd34a1b8",
        "D_NG_J12": "一",
        "N_ZHU_NG_Y_O_QI": "合格",
        "G_NG_CH_NG_M_NG_CH_NG_ID": None,
        "STUDIO_INDEX": None,
        "J_Z_H_O": "2",
        "PROCESS_HANDLER_NAMES": "唐鹏",
        "Y_N_H_NG_X_NG_N_NG2_ID": "1",
        "LI_N_ZH_U1_ID": "1",
        "D_NG_J8_ID": "1",
        "Y_PI_N4_ID": "1",
        "updater": "唐鹏",
        "D_NG_J10": "一",
        "D_NG_J11": "一",
        "B_I_ZH10": None,
        "B_I_ZH11": None,
        "B_I_ZH12": None,
        "ZH_SH_X_N_H_O2_ID": "1",
        "D_NG_J5_ID": "1",
        "Y_PI_N1_ID": "1",
        "R_L_I_SH_LI_NG": None,
        "Z_R_N_R_N": "徐楠",
        "D_NG_J10_ID": "1",
        "Y_PI_N1": "合格",
        "Y_PI_N2": "合格",
        "Y_PI_N3": "合格",
        "Y_PI_N4": "合格",
        "SHU_B_NG_W_I_K1": "合格",
        "SHU_B_NG_W_I_K2": "合格",
        "Y_L_N_SH2_ID": "1",
        "J_N_R_N_K_NG": "合格",
        "deletor_id": None,
        "TI_N_LI_O": "合格",
        "SHU_B_NG_W_I_K1_ID": "1",
        "J_L_R_N": "徐楠"
    },
    "userInfo": {
        "userId":
        userId,
        "sex":
        1,
        "username":
        "lljtp",
        "realname":
        "唐鹏",
        "telephone":
        "",
        "mail":
        "",
        "icon":
        "",
        "userNum":
        "",
        "mobile":
        "18860802114",
        "userCipher":
        "11ec567bd7cf5425b8290514a779f120",
        "remark":
        "LLJ",
        "status":
        1,
        "credentialsSalt":
        "lljtpc49f39c160648a789150f0a4fbc5609f",
        "sysDepts": [{
            "deptId": "2eb5c7e441e0485982a9c4664900f4c2",
            "code": "",
            "name": "刘老涧闸站管理所",
            "level": "/ecd1044a2c734cb68fa0497dcdd98d2f",
            "seq": 0,
            "remark": "LLJ",
            "parentId": "ecd1044a2c734cb68fa0497dcdd98d2f",
            "status": 1,
            "type": 8,
            "director": "",
            "directorId": "",
            "facsimile": "",
            "phone": "",
            "modelId": "",
            "organizationId": None,
            "authLevel": None,
            "deptStationRequestList": []
        }],
        "individuation":
        None,
        "signatrue":
        None,
        "applicationRole":
        "1",
        "lastTimeLogin":
        None,
        "loginTime":
        1724637806384,
        "organizationId":
        "ecd1044a2c734cb68fa0497dcdd98d2f",
        "lastTimeUpdPwd":
        1717663069788,
        "seq":
        999999,
        "appKey":
        "e05cee4fd4e04765a9b7b335db1c7004",
        "type":
        0,
        "postId":
        "",
        "postName":
        None,
        "userGroups":
        None,
        "createTime":
        1717663069788,
        "ssoOrgId":
        None,
        "ssoOrgName":
        None,
        "expiresDate":
        None,
        "online":
        False,
        "REALNAME":
        "唐鹏",
        "USERID":
        userId,
        "id":
        userId,
        "name":
        "唐鹏",
        "ID":
        userId,
        "NAME":
        "唐鹏",
        "token":
        token
    }
}

resp = session.post(url=f"{BASEURL}{SAVE}", headers=HEADERS, json=save_json)
print(resp.json())

# 更新
UPDATE = "/precimng/equipRating/update"
update_json = {
    "id": "b9b811785a224934b26abbf863f72962",
    "equipId": "5075fc70afa84789b101482423a70745",
    "attrIds": [],
    "experimentDate": "",
    "overhaulDate": "",
    "selfDate": "2024-03-14",
    "selfLevel": "Ⅰ",
    "selfPerson": "d136a5a3f12543d59b5c1e72bd34a1b8",
    "state": "save",
    "equipDirectoryId": "",
    "engineeringId": "ba8e413876f346f4a244ae7d1e272ba1",
    "createdDate": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
    "workorderId": "3d9d1e63460e4ec4957d8c3f54f51fe5",
    "modelKey": None,
    "modelName": "主水泵评级表"
}
resp = session.post(url=f"{BASEURL}{UPDATE}",
                    headers=HEADERS,
                    json=update_json)
print(resp.json())
# 查询
SELECT = "/studio-server/api/flow/init"
# save_json = {}
# resp = session.post(url=f"{BASEURL}{SAVE}", headers=HEADERS, json=save_json)
# print(resp.json())
